#!/bin/bash

./total "$1"|tr '\t' '\n'|sed 's/\[//g;s/\]//g'|sed '/^$/d'>chart.dat
if [[ $1 =~ .*\-.* ]]; then
	y=5000;x=32;t="日期"
else
	y=50000;x=13;t="月份"
fi

gnuplot << EOF
#!/usr/bin/gnuplot
# set term png font "/home/exp/.fonts/●可用字体/YuanTi/VeraSansYuanTi-Regular.ttf,12"
d="$1"
set term png font "./yuanti.ttf,9"
f="gnuplot-".d.".png"
# f="gnuplot.png"
# set term png font "/usr/share/fonts/truetype/arphic/gkai00mp.ttf,12"
set xrange [0:$x]
set yrange [0:$y]
set xlabel "$t"
set ylabel "金额"
set xtics 1
set output f
set title "easy-account 图表统计：".d
set boxwidth 0.8 absolute
set style fill solid 1.0
plot 'chart.dat' using 1:2 with boxes
print f
EOF

feh gnuplot-"$1".png
